package com.conversationboard.batch.jobs.loghousekeeping;

import java.sql.SQLException;
import java.util.Date;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.conversationboard.logger.LogMessageType;
import com.conversationboard.logger.Logger;
import com.conversationboard.model.Log;

/**
 * Batch job to clear out the error logs.
 * 
 * @author Keith Watson
 * 
 */

public class UserLogHousekeepingJob implements Job {

	public void execute(JobExecutionContext context) throws JobExecutionException {

		try {
			long startTime = System.currentTimeMillis();
			
			Log.clearOldUserLog();
			
			long timeTaken = System.currentTimeMillis() - startTime;
			Logger.log(new Date(), "User Housekeeping Job took: " + timeTaken + " milliseconds", null, LogMessageType.DEBUG);

		} catch (SQLException e) {
			throw new JobExecutionException(e);
		}

	}

}
